package com.sunreal.paygateway.sys.exception;

/**
 * 功能描述：//TODO
 *
 * @Author 彭广
 * @Date 2018/11/29
 */
public enum WebErrCode {
    /**验签失败*/
    SIGN_VERIFY_FAILED(400001,"验签失败！"),


    //************************统一下单错误提示 START*********************************/
    /**订单已存在*/
    PAYORDER_EXISTS(500001,"订单已存在！"),
    /**支付中心下单失败*/
    CREATE_PAYORDER_FAILED(500002,"支付中心下单失败！"),
    /**打开订单支付页面失败*/
    OPEN_ORDER_PAGE_FAILED(500003,"打开订单支付页面失败！"),
    /**调用第三方(微信或支付宝)支付失败*/
    PAY_FAILED(500004,"调用第三方支付失败！"),
    //**********************统一下单错误提示 END*********************************/


    //********************* 与二掌柜后台单位端业务接口相关***********************/
    /**参数验证错误*/
    ERROR_PARAMS(99999,"参数验证错误！");


    private Integer erroCode;
    private String errorMsg;

    WebErrCode(Integer erroCode, String errorMsg) {
        this.setErroCode(erroCode);
        this.setErroMsg(errorMsg);
    }
    // 普通方法
    public static String getErroMsg(int erroCode) {
        for (WebErrCode c : WebErrCode.values()) {
            if (c.getErroCode() == erroCode) {
                return c.errorMsg;
            }
        }
        return null;
    }
    public Integer getErroCode() {
        return erroCode;
    }

    public void setErroCode(Integer erroCode) {
        this.erroCode = erroCode;
    }

    public String getErroMsg() {
        return errorMsg;
    }


    public void setErroMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    @Override
    public String toString() {
        return "[" + this.erroCode + "]" + this.errorMsg;
    }
}
